package javaBase.nowcoder.HJ99_A_自守数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Integer num = Integer.parseInt(br.readLine());
        int count = 0;
        for (int i = 0; i <= num; i++) {
            if ((i * i + "").substring((i * i + "").length() - (i + "").length()).equals(i + "")) {
                count++;
            }
        }
        System.out.println(count);
    }
}
